home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: Amit Ramon <amitra@ix.netcom.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Visual C++ Serializing CStrings
- Date: 26 Feb 1996 04:39:44 GMT
- Organization: Netcom
- Message-ID: <4grdig$rhr@cloner4.netcom.com>
- References: <4gjjuo$poc@newshound.csrv.uidaho.edu>
- NNTP-Posting-Host: ix-stl3-16.ix.netcom.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-NETCOM-Date: Sun Feb 25 8:39:44 PM PST 1996
- X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
-
- CArchive can serialize any CObject derive class that implement the
- Serialize(CArchive& ar) function. If e.g, CMyClass is derived from CObject,
- and myObject is an instance of CMyClass, you can serialize it by calling
- myObejct.Serialize(ar), where ar is an instance of CArchive. See the
- 'scribble' example that comes with VC++ for details.
-
- You can also serialize non CObject derive classes, like CString,
- by using operator<<(CArchive& ar, CString& str) or
- operator>>(CArchive& ar, CString& str). For example:
-
- CArchive ar;
-
- // open ar and attach it to a file
-
- CString str = "1234"
- ar << str;
-
- This should work. Maybe you're trying to serialize an object that wasn't
- derived from CObject?
-
- Amit.
-
-